<template>
  <section class="timeline-section ">
    <div class="container text-center">
      <h2 class="section-title">
        {{ title }}
      </h2>
      <div class="timeline">
        <ul>
          <li v-for="(item, index) in milestoneList" :key="index" :class="item.important ? 'featured acquisition' : ''">
            <div>
              <h5>
                {{ item.label }}
              </h5>
            </div>
          </li>
        </ul>
      </div>
    </div>
  </section>
</template>
<script lang="ts">
import { Component, Prop, Vue } from "vue-property-decorator";

@Component
export default class milestone extends Vue {
  @Prop({
    default: "Milestone",
    type: String,
  })
  title!: string; // 标题
  @Prop({
    required: true,
  })
  milestoneList!: Array<{}>; // 里程碑内容
}
</script>

<style lang="less" scoped>
/* ========== timeline ========== */
*,
::after,
::before {
  box-sizing: border-box;
}

section {
  padding: 80px 0;

  .text-center {
    text-align: center !important;
  }

  .container {
    width: 100%;
    padding-right: 15px;
    padding-left: 15px;
    margin-right: auto;
    margin-left: auto;

    .section-title {
      text-align: center;
      margin-left: auto;
      margin-right: auto;
      max-width: 850px;
    }
  }
}

.timeline {
  position: relative;

  &::before {
    left: -12px;
    content: "";
    position: absolute;
    height: 100%;
    width: 1px;
    background: #e1e1e1;
  }

  ul {
    list-style: none;
    z-index: 1;
    padding: 0;
    max-width: 800px;

    li {
      margin-bottom: 2em;
      position: relative;
      display: block;
      text-align: left;
      padding-left: 30px;

      div {
        h5 {
          color: #8f9daa;
          line-height: 18px;
          font-size: 14px;
          margin: 0;
          word-wrap: break-word;
        }
      }
    }

    li.featured {
      h5 {
        color: #fff;
      }
    }
  }
}

.timeline li::before {
  content: "";
  top: 0;
  background: #e1e1e1;
  width: 18px;
  height: 18px;
  border-radius: 18px;
  position: absolute;
  left: -21px;
}

@media only screen and (min-width: 768px) {
  .timeline {
    padding-bottom: 4rem;
  }

  .timeline::before {
    left: 50%;
  }

  .timeline ul {
    padding-left: 0;
    margin: 0 auto;
  }

  .timeline li {
    width: 50%;
  }

  .timeline li {
    padding-left: 45px;
    position: relative;
    margin-left: 50%;
  }

  .timeline li::before {
    left: -9px;
  }

  .timeline li.featured {
    padding-left: 0;
    padding-right: 45px;
    margin-left: 0;
  }

  .timeline li.featured::before {
    right: -9px;
    top: 18px;
    left: auto;
  }

  .timeline li.featured > div {
    padding: 1rem 1rem 0.15rem;
    background: #e1e1e1;
    border-radius: 5px;
    position: relative;
  }

  .timeline li.featured > div::after {
    content: "";
    position: absolute;
    right: -12px;
    top: 20px;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 8px 0 8px 12px;
    border-color: transparent transparent transparent #e1e1e1;
  }

  .timeline li:first-child {
    margin-top: 4em;
  }

  .timeline li:nth-of-type(2n + 1) {
    clear: both;
  }
}

.timeline li.featured > div {
  background: #e1e1e1;
  padding: 6px 18px;
  border-radius: 0;
}

.timeline li.featured.acquisition:before,
.timeline li.featured.acquisition > div {
  background: #22b8eb;
  color: #fff;
}

.timeline li.featured.acquisition > div::after {
  border-color: transparent transparent transparent #22b8eb;
}

.timeline li.featured.launch:before,
.timeline li.featured.launch > div {
  background: #86d800;
  color: #fff;
}

.timeline li.featured.launch > div::after {
  border-color: transparent transparent transparent #86d800;
}

.timeline li.featured.funding:before,
.timeline li.featured.funding > div {
  background: #ffde00;
  color: #fff;
}

.timeline li.featured.funding > div::after {
  border-color: transparent transparent transparent #ffde00;
}

.timeline li.featured {
  padding-right: 30px;
  padding-left: 0;
}

.timeline li.featured > div iframe {
  width: 100%;
  margin-top: 20px;
}

.timeline li.featured::before {
  top: 6px;
}

.timeline li.featured > div::after {
  top: 10px;
  right: -5px;
  border-width: 5px 0 5px 5px;
}

.timeline li.featured > div::before {
  content: "";
  position: absolute;
  right: 0;
  top: 10px;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 5px 5px 5px 0;
  border-color: transparent transparent transparent transparent;
}

.timeline li.featured.acquisition > div::before {
  border-color: transparent #22b8eb transparent transparent;
}

.timeline li.featured.launch > div::before {
  border-color: transparent #86d800 transparent transparent;
}

.timeline li.featured.funding > div::before {
  border-color: transparent #ffde00 transparent transparent;
}

.timeline li.featured.funding > div h5 {
  color: #445d6e;
}

@media only screen and (max-width: 767px) {
  .timeline li.featured {
    padding-right: 0;
    padding-left: 15px;
  }

  .timeline li.featured > div::before {
    left: 10px;
    right: inherit;
  }
}
</style>
